package com.medvalley.tcm.controller;

import com.medvalley.tcm.base.Result;
import com.medvalley.tcm.service.impl.WenZhenService;
import com.medvalley.tcm.vo.inputvo.SickInfoSearchInputVo;
import com.medvalley.tcm.vo.inputvo.WenZhenTizhiInputVo;
import com.medvalley.tcm.vo.inputvo.WenZhenZhenXingInputVo;
import com.medvalley.tcm.vo.outputvo.WenZhenOutputVo;
import com.medvalley.tcm.vo.outputvo.WenZhenReportOutputVoBrief;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api("青岛河北问诊接口")
@RequestMapping("/wenzhen")
public class WenZhenController extends BaseController {

    @Autowired
    private WenZhenService wenZhenService;


    @PostMapping("/tizhi_save")
    @ApiOperation("保存体质信息")
    public Result saveTizhiInfo(@ModelAttribute WenZhenTizhiInputVo wenZhenTizhiInputVo) {
        wenZhenService.saveTizhi(wenZhenTizhiInputVo);
        return success();
    }

    @PostMapping("/zhengxing_save")
    @ApiOperation("保存证型信息")
    public Result saveZhengXingInfo(@ModelAttribute WenZhenZhenXingInputVo wenZhenZhenXingInputVo) {
        wenZhenService.saveZhengXing(wenZhenZhenXingInputVo);
        return success();
    }

    @GetMapping("/wen_zhen_detail")
    @ApiOperation("问诊详情")
    public Result detail(@RequestParam(name = "wen_zhen_id") long id) {
        WenZhenOutputVo detail = wenZhenService.getDetail(id);
        return success(detail);
    }

    @ApiOperation("问诊检索")
    @GetMapping("/wen_zhen_search")
    public Result search(@ModelAttribute SickInfoSearchInputVo wenZhenSearchInputVo) {
        List<WenZhenReportOutputVoBrief> wenZhenReportOutputVoBriefs = wenZhenService.search(wenZhenSearchInputVo);
        return success(wenZhenReportOutputVoBriefs);
    }

}
